<template>
	<view>
		<view class="content" v-if="list.length">
			<view class="list_box" v-for="item in list" :key="item.id">
				<view class="list_left">
					<view class="name">{{item.title}}</view>
					<view class="data">{{item.createTime}}</view>
				</view>
				<view class="list_right" style="color: red;" v-if="item.type==1">- {{item.money}}</view>
				<view class="list_right" style="color: #33D442;" v-if="item.type==2">+ {{item.money}}</view>
			</view>
		</view>
		<empty v-else ></empty>
	</view>
</template>

<script>
	import empty from '@/components/empty'
	export default {
		components: {
			empty
		},
		data() {
			return {
				page:1,
				limit:10,
				totalCount:0,
				list: []
			}
		},
		onLoad() {
			this.taskData()
		},
		methods: {
			// 获取任务数据
			taskData() {
				let userId = this.$queue.getData('userId');
				this.$Request.getT('/app/userMoney/profitDetailed',{
					userId:userId,
					page:this.page,
					limit:this.limit
				}).then(res => {
					if(res.code==0){
						if (this.page == 1) {
							this.list = res.data.data.list
						} else {
							this.list = this.list_box.concat(res.data.data.list)
						}
						this.totalCount = res.data.data.totalCount
					}
					console.log('res',res) 
					
				});
			},
		},
		// 上拉加载
		onReachBottom: function() {
			if(this.page<this.totalCount){
				this.page = this.page + 1;
			}else{
				uni.showToast({
					title:'已经最后一页啦',
					icon:'none'
				})
			}
			
			this.taskData();
		}
	}
</script>

<style>
	body {
		background: #F5F5F5;
	}

	.content {
		width: 100%;
		background: #FFFFFF;
		margin-top: 20rpx;
		padding-bottom: 50rpx;
		padding-top: 20rpx;
	}

	.list_box {
		width: 90%;
		margin: 0 auto;
		display: flex;
		line-height: 45rpx;
		padding-top: 20rpx;
	}

	.list_left {
		flex: 2;
	}

	.name {
		font-size: 26rpx;
		color: #333333;
		font-weight: bold;
		letter-spacing: 2rpx;
	}

	.data {
		color: #999999;
		font-size: 24rpx;
	}

	.list_right {
		flex: 1;
		display: flex;
		justify-content: flex-end;
		align-items: center;
		font-size: 31rpx;
	}
</style>
